<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
    <title>奖品列表</title>
    <%@include file="common/include.jsp" %>
    <style type="text/css">
    	.thclass{
    	 width:25%;
    	}
    	#operation{
    		width:60px;
    	}
    	
    	#goPrizeRecord{
    		position: absolute;
    		left: 630px;
    		top: 50px;
    	}
    	
    </style>
    
    
    
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-lg-8">
            <br/>
            <div id = "goPrizeRecord">
            	<button type="button" onclick="goPrizeRecord()" class="btn btn-default">抽奖记录</button>
            </div>
            <div class="panel panel-default">
                <div class="panel-body">
                	<h3 style="color:gay; font-family:"SimHei";">
						奖品列表
					</h3>
                </div>
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th class = "thclass">ID</th>
                        <th class = "thclass">奖品名称</th>
                        <th class = "thclass">奖品类型</th>
                        <th class = "thclass">奖品价值</th>
                        <th class = "thclass">概率权重</th>
                        <th class = "thclass">14日限定值</th>
                        <th class = "thclass">15日限定值</th>
                        <th class = "thclass">16日限定值</th>
                        <th class = "thclass">17日限定值</th>
                        <th class = "thclass">18日限定值</th>
                        <th id = "operation">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="prize" items="${prizeList}">
                        <tr>
                            <td>${prize.id}</td>
                            <td>${prize.name}</td>
                            <td>${prize.desc}</td>
                             <td>${prize.price}</td>
                             <td>${prize.weight}</td>
                             <td>${prize.day14}</td>
                             <td>${prize.day15}</td>
                             <td>${prize.day16}</td>
                             <td>${prize.day17}</td>
                             <td>${prize.day18}</td>
                            <td>
                                <a href="javascript:void(0);" onclick="preSave('${prize.id}')" title="编辑">
                                    <i class="glyphicon glyphicon-edit"></i>
                                </a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    function preSave(id) {
        if (id == undefined || id == null || id == '') {
            //window.location.href = '${ctx}/user/preSave';
            return;
        } else {
            window.location.href = '${ctx}/prize/preSave?id=' + id;
        }
    }
    
    function goPrizeRecord() {
    	window.location.href = '${ctx}/prize/listPrizeRecord';
	}

    function del(id) {
        $.ajax({
            type: 'POST',
            url: '${ctx}/user/delete',
            data: {
                id: id
            },
            dataType: 'json',
            success: function (data) {
                alert(data.msg);
                if (data.success) {
                    setTimeout('toIndex()', 100);
                }
            },
            error: function () {
                alert("出错了,请重试!");
            }
        });
    }
</script>
</body>
</html>
